<template>
    <div
        @click.stop
        id="map"
        class="tools_item_left"
        :style="[
            {
                left: `-${item.left}px
                        `,
            },
        ]"
    >
        <template v-if="item.father === '用户作业轨迹'">
            <userForm
                @queryToolsUserTraJectory="queryToolsUserTraJectory"
            ></userForm>
        </template>

        <template v-else>
            <CommonIconList
                :item="item"
                @changeLayer="changeLayer"
            ></CommonIconList>
        </template>
    </div>
</template>

<script setup lang="ts">
import type { children } from "@/components/map/components/mapToolsItem/index";

const emit = defineEmits(["changeLayer", "queryToolsUserTraJectory"]);
const props = defineProps({
    item: {
        required: true,
        default: {} as children,
    },
});

const getActiveSty = (isActive: boolean) => {
    if (isActive) return "active";
};

// 切换图层
const changeLayer = (obj: any) => {
    obj.item.iconList.forEach((ele: any) => {
        ele.isActive = ele.text === obj.ele.text;
    });
    emit("changeLayer", obj);
};

// 查询作业轨迹
const queryToolsUserTraJectory = (obj: any) => {
    emit("queryToolsUserTraJectory", obj);
};

onMounted(() => {});
</script>

<style lang="scss" scoped>
.active {
    color: red;
}
.tools_item_left {
    font-size: 12px;
    position: absolute;
    top: -66px;
    left: -210px;
    border-radius: 12px;
    background-color: #e6eef9;
    padding: 8px 12px;
    border: 1px solid #c0c4cc;
    color: #c0c4cc;
    transition: color 0.15s ease-in;
    box-shadow:
        0 0 1px 0 rgba(24, 94, 224, 0.15),
        0 6px 12px 0 rgba(24, 94, 224, 0.15);
    ul {
        cursor: pointer;
        display: flex;
        flex-wrap: nowrap;
        overflow: hidden;
        overflow-x: scroll;
        @include flexLayout;
        li {
            @include flexLayout;
            display: flex;
            flex-direction: column;
            margin-left: 8px;
            &:first-child {
                margin-left: 0;
            }

            span {
                margin-top: 6px;
                box-shadow:
                    0 0 1px 0 rgba(24, 94, 224, 0.15),
                    0 6px 12px 0 rgba(24, 94, 224, 0.15);
            }
            .iconClass {
                border-radius: 12px;
            }
        }
    }
}
</style>
